package epin.fujiajun.sort.primary;


import epin.fujiajun.data.Array;
import epin.fujiajun.data.array.Number;
import epin.fujiajun.sort.ArraySortBase;


/**
 * Created by DELL on 2017/8/15.
 */
public class Insertion extends ArraySortBase {

    @Override
    public void sort(Array[] a) {
        int N = a.length;

        for (int i = 1; i < N; i++){
            for (int j = i; j >= 1 && less(a[j], a[j-1]); j -= 1){
                exChange(a, j, j-1);
            }
        }
    }


    public static void main(String[] args){
        new Insertion().main(Number.createArray(100, 1000));
    }
}
